//菜单模块相关接口
import request from "@/utils/request.ts";
import type { menuResponseData } from "./type";
enum API {
  // GET
  permission = "/admin/acl/permission",
  // 获取菜单

  // POST
  doAssignAcl = "/admin/acl/permission/doAssignAcl",
  // 给角色分配权限

  // DELETE
  remove = "/admin/acl/permission/remove",
  // 递归删除菜单

  // POST
  save = "/admin/acl/permission/save",
  // 新增菜单

  // PUT
  update = "/admin/acl/permission/update",
  // 修改菜单
}

export const permission = () => {
  return request.get<any, menuResponseData>(API.permission);
};

export const doAssignAcl = (roleId: number, permissionIdList: number[]) => {
  let data = { roleId, permissionIdList };
  return request.post<any, any>(API.doAssignAcl, data);
};

export const remove = (id: any) => {
  return request.delete<any, any>(API.remove + `/${id}`);
};

export const save = (data: any) => {
  return request.post<any, any>(API.save, data);
};

export const update = (data: any) => {
  return request.put<any, any>(API.update, data);
};
